package simulation;

import util.Vector;

/**
 * Create center of mass force by extending force class
 * @author Gavin Ovsak
 */
public class ViscocityForce extends Force {
    private double myViscosity;
    
    /**
     * Constructor for gravity force
     * @param index 
     * @param viscocity  
     */
    public ViscocityForce(int index, double viscocity) {
        super(index);
        myViscosity = viscocity;
    }
    
    /**
     * Apply force to a Mass.
     * @param m 
     */
    @Override
    public void applyForce(Mass m) {
        if (isActive()) {
            m.applyForce(new Vector(m.getVelocity().getDirection() + Model.HALF_TURN,
                                    m.getVelocity().getMagnitude() * myViscosity));
        }
    }
}